<template>
  <el-card>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="评分管理" name="score_manage" />
      <el-tab-pane label="分级依据" name="triage_manage" />
      <el-tab-pane label="菜单管理" name="menu_manage" />
      <el-tab-pane label="设置必填项" name="set_requireditems" />
      <el-tab-pane label="档案管理" name="file_management" />
      <el-tab-pane label="病史管理" name="medicalHistory_manage" />
    </el-tabs>
    <component :is="activeName" />
  </el-card>
</template>

<script>
import score_manage from '@/views/back-management/triage-set/score_manage'
import triage_manage from '@/views/back-management/triage-set/Triage_manage'
import file_management from '@/views/back-management/triage-set/File_management'
import set_requireditems from '@/views/back-management/triage-set/Set_requiredItems'
import menu_manage from '@/views/back-management/triage-set/Menu_manage'
import medicalHistory_manage from '@/views/back-management/triage-set/MedicalHistory_manage'
export default {
  name: 'TriageManagement',
  components: { triage_manage, file_management, set_requireditems, score_manage, menu_manage, medicalHistory_manage },
  data() {
    return {
      activeName: 'score_manage'
    }
  },

  created() {
    // 添加刷新监听,刷新后保持tab页选中
    window.addEventListener('beforeunload', e => this.beforeunloadFn(e))
    this.activeName = sessionStorage.getItem('activeName') || this.activeName
  },
  beforeDestroy() {
    // 卸载监听事件
    window.removeEventListener('beforeunload', e => this.beforeunloadFn(e))
    // 清除sessionStorage
    sessionStorage.removeItem('activeName')
  },
  methods: {
    handleClick(tab, event) {
      // console.log(tab, event)
    },
    // 存储sessionStorage
    beforeunloadFn(e) {
      sessionStorage.setItem('activeName', this.activeName)
      // console.log('刷新或关闭')
    }
  }
}
</script>

<style>
</style>
